﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>溶栓取栓统计</title>
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/ligerui-icons.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Gray/css/all.css" />
    <link rel="stylesheet" href="~/Content/css/common.css" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
</head>
<body>
    <div class="searchbar">
        <div class="sblabel">
            开始时间：
        </div>
        <div class="sbligerControl">
            <input type="text" id="txtStartTime" value="@(ViewBag.StartTime)" />
        </div>
        <div class="sblabel">
            结束时间：
        </div>
        <div class="sbligerControl">
            <input type="text" id="txtEndTime" value="@(ViewBag.EndTime)" />
        </div>
        <div class="sblabel">
            统计类型：
        </div>
        <div class="sbligerControl">
            <input type="text" id="ddlDateType" />
        </div>
        <div class="sbligerButton">
            <input id="btnSearch" type="button" value="查询" class="l-button" />
        </div>
    </div>
    <div id="maingrid"></div>
</body>
</html>
<script>
    $(function () {
        $("#txtStartTime,#txtEndTime").ligerDateEditor({
            showTime: false,
            format: "yyyy-MM-dd",
            width: 140,
            cancelable: false
        });

        $("#ddlDateType").ligerComboBox({
            width: 60,
            cancelable: false,
            valueFieldID: 'hdnDateType',
            data: [
                  { id: 1, text: "天" },
                  { id: 2, text: "月" },
                  { id: 3, text: "年" }
            ],
            onSelected: function (value) {
                switch (value) {
                    case "1":
                        $("#txtStartTime").ligerDateEditor().setEnabled();
                        $("#txtEndTime").ligerDateEditor().setEnabled();
                        break;
                    case "2":
                        $("#txtStartTime").val(getMonthFirstDay());
                        $("#txtStartTime").ligerDateEditor().setDisabled();
                        $("#txtEndTime").val(getMonthLastDay());
                        $("#txtEndTime").ligerDateEditor().setDisabled();
                        break;
                    case "3":
                        $("#txtStartTime").val(getYearFirstDay());
                        $("#txtStartTime").ligerDateEditor().setDisabled();
                        $("#txtEndTime").val(getYearLastDay());
                        $("#txtEndTime").ligerDateEditor().setDisabled();
                        break;
                }
            }
        });
        $("#ddlDateType").ligerComboBox().setValue("2");

        $('#btnSearch').click(function () {
            search();
        });

        $('#btnSearch').click();
    });

    function search(pageNumber) {
        var queryData = {
            startTime: $("#txtStartTime").val(),
            endTime: $("#txtEndTime").val(),
            dateType: $("#hdnDateType").val()
        }
        initTable(queryData, pageNumber);
    }

    function initTable(queryData, pageNumber) {
        $("#maingrid").ligerGrid({
            height: '100%',
            url: '/StrokeCenter/JmrsxgnjrzlStatistics/SearchRongShuanQuShuan?ram=' + Math.random(),
            parms: queryData,
            page: pageNumber,
            pageSize: 30,
            rownumbers: false,
            usePager: false,
            heightDiff: 25,
            columns: [
                { display: '名称', name: 'titleName' },
                { display: '本期值', name: 'nowNum' },
                { display: '上期值', name: 'nearNum' },
                { display: '去年同期值', name: 'befNum' },
                {
                    display: '同比增长率（%）', name: '', render: function (row) {
                        if (row.befNum > 0) {
                            return ((row.nowNum - row.befNum) / row.befNum * 100).toFixed(2);
                        }
                    }
                },
                {
                    display: '环比增长率（%）', name: '', render: function (row) {
                        if (row.nearNum > 0) {
                            return ((row.nowNum - row.nearNum) / row.nearNum * 100).toFixed(2);
                        }
                    }
                }
            ]
        });
        GridNoData($("#maingrid"));
    }
</script>